import { Component } from '@angular/core';
import { IonicPage, NavController, ViewController, NavParams } from 'ionic-angular';
import { HttpProvider } from '../../providers/http/http';
import { StorageProvider } from '../../providers/storage/storage';
import { DialogProvider } from '../../providers/dialog/dialog';
import { AboutusDataService } from '../../providers/service/aboutus-data.service';
import { Network } from '@ionic-native/network';


/**
 * Generated class for the AboutUsPage page.
 *
 * See https://ionicframework.com/docs/components/#navigation for more info on
 * Ionic pages and navigation.
 */

@IonicPage()
@Component({
  selector: 'page-about-us',
  templateUrl: 'about-us.html',
})
export class AboutUsPage {

  abouts: About[] = new Array<About>();
  // public abouts: about = {
	// 	DoubtOverdue: "",
	// 	QQ: "",
	// 	Email: "",
	// 	Phone: "",
  //   Introduction: "",
  //   WX: "",
  // }
  //有网状态=1 断网=0
	Internet = 1;
  
  
  
  constructor(
    public navCtrl: NavController,
    public viewCtrl: ViewController,
    public http: HttpProvider,
    public storage: StorageProvider,
    public aboutus: AboutusDataService,
    private network: Network,
    public dialog: DialogProvider) { }

  async ionViewDidLoad() {
    console.log('ionViewDidLoad AboutUsPage');
    if(this.network.type!=='none' && this.network.type !== '2g'){ //navigator.onLine
			this.Internet=1;
      this.getAbountus();
		}
		if(this.network.type === 'none' || this.network.type === '2g'){
			this.Internet=0;
			let a = await this.aboutus.find((abouts) => abouts.key !=='');
			this.abouts=a[0];
		}
    
  }

  async getAbountus() {
    this.http.postJson('', 'system/chargeu/getbasicinfo',
      {
      
      }, '').then(res => {
        console.log(res)
        if (res['status'] == 200) {
          this.abouts=res['data'];
          this.aboutus.deleteAll();
          this.aboutus.save(this.abouts);
          
        }
      });
  }

 
  
}



export class About {
  DoubtOverdue: any;
  QQ: any;
  Email: any;
  Phone: any;
  Introduction: any;
  WX: any;
}
